﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using CustomsSystem.DAL;


namespace CustomsSystem.BLL
{
    
        /// <summary>
	/// users
	/// </summary>
	public partial class UserManage
	{
		private readonly CustomsSystem.DAL.UserService  dal=new CustomsSystem.DAL.UserService ();
		
		#region  Method

		/// <summary>
		/// 得到最大ID
		/// </summary>
		public int GetMaxId()
		{
			return dal.GetMaxId();
		}

		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(int id)
		{
			return dal.Exists(id);
		}

        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool ExistName(string UserName)
        {
            return dal.ExistName(UserName);
        }

		/// <summary>
		/// 增加一条数据
		/// </summary>
        public int Add(CustomsSystem.Model.Users  model)
		{
			return dal.Add(model);
		}

		/// <summary>
		/// 更新一条数据
		/// </summary>
        public bool Update(CustomsSystem.Model.Users model)
		{
			return dal.Update(model);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(int id)
		{
			
			return dal.Delete(id);
		}
		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool DeleteList(string idlist )
		{
			return dal.DeleteList(idlist );
		}

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
        public CustomsSystem.Model.Users GetModel(string EMPNUM)
		{
			
			return dal.GetModel(EMPNUM);
		}

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public CustomsSystem.Model.Users GetModel(string UserName, string PassWord)
        {

            return dal.GetModel(UserName, PassWord);
        }

        /// <summary>
        /// 根据用户名得到用户ID
        /// </summary>
        public object GetSingle(string SQLString)
        {
            return dal.GetSingle(SQLString);
        }

		

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			return dal.GetList(strWhere);
		}
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetMyList(string strWhere)
        {
            return dal.GetMyList(strWhere);
        }
		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			return dal.GetList(Top,strWhere,filedOrder);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
        public List<CustomsSystem.Model.Users> GetModelList(string strWhere)
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
        public List<CustomsSystem.Model.Users> DataTableToList(DataTable dt)
		{
            List<CustomsSystem.Model.Users> modelList = new List<CustomsSystem.Model.Users >();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
                CustomsSystem.Model.Users model;
				for (int n = 0; n < rowsCount; n++)
				{
                    model = new CustomsSystem.Model.Users();
					if(dt.Rows[n]["id"].ToString()!="")
					{
						model.Id =int.Parse(dt.Rows[n]["id"].ToString());
					}
                    model.EmpNum = dt.Rows[n]["EmpNum"].ToString();
                    model.UserName = dt.Rows[n]["UserName"].ToString();
                    model.JobNo = dt.Rows[n]["JobNo"].ToString();
					modelList.Add(model);
				}
			}
			return modelList;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetAllList()
		{
			return GetList("");
		}

		/// <summary>
		/// 分页获取数据列表
		/// </summary>
	//	public DataSet GetList(int PageSize,int PageIndex,string strWhere)
	//	{
	//		return dal.GetList(PageSize,PageIndex,strWhere);
	//	}

		#endregion  Method
	}
}
